package com.feicheng.controller.system;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.feicheng.common.constant.Constant;
import com.feicheng.common.exception.SystemException;
import com.feicheng.common.result.ResultInfo;
import com.feicheng.persistence.entity.Client;
import com.feicheng.persistence.entity.Role;
import com.feicheng.persistence.mapper.ClientMapper;
import com.feicheng.persistence.service.IClientService;
import com.feicheng.service.a.FJlService;
import com.feicheng.service.a.FXyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cailongyang
 * @since 2024-08-21
 */
@RestController
@RequestMapping("/admin/client")
public class ClientController {
    @Autowired
    FXyService xyService;

    @Autowired
    FJlService jlService;
    
    @Autowired
    FXyService xyServicej;

    /**
     * wumingxia 会员分页
     */
    @GetMapping("/hyjl/page")
    public ResultInfo getHyjlByPage(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "12") Integer size,
            String searchKey
    ) {
        JSONObject param = new JSONObject();
        param.put("current", current);
        param.put("size", size);
        param.put("jlname", searchKey);
        param.put("hlname", searchKey);
        param.put("nc", searchKey);
        param = xyService.getHysByPage(param);
        System.out.println("param:" + param);
        return ResultInfo.success(param.get("ahyjls"));
    }

    /**
     * wumingxia 会员详细
     */
    @GetMapping("/hyjl/info")
    public ResultInfo getHyjlInfo(String clientid, String hyjlid) {
        JSONObject param = new JSONObject();
        param.put("hyjlid", hyjlid);
        System.out.println("数据快来"+hyjlid);
        param = xyService.getHyjl(param);
        return ResultInfo.success(param);
    }

    /**
     * jiachunlei 会员类型分页
     */
    @GetMapping("/hylx/page")
    public ResultInfo getByPage(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "12") Integer size,
            String searchKey
    ) {
        JSONObject param = new JSONObject();
        param.put("current", current);
        param.put("size", size);
        param.put("jlid", searchKey);
        param.put("jlname", searchKey);
        param = jlService.getHylxs(param);
        return ResultInfo.success(param);
    }

    /**
     * jiachunlei 会员类型详细
     */
    @GetMapping("/hylx/info")
    public ResultInfo getByPages(
            String hylxid
    ) {

        JSONObject param = new JSONObject();
        param.put("hylxid", hylxid);
        param = jlService.getHylx(param);
        JSONObject jlParam = new JSONObject();
        jlParam.put("jlid", param.getString("jlid"));
        param.put("ajiaolian",jlService.getJl(jlParam));
        JSONObject hysparam = new JSONObject();
        hysparam.put("hylxid", hylxid);
        param.put("ahyjl",xyServicej.getHys(hysparam));
        return ResultInfo.success(param);
    }

    /**
     * shihuijun 报名分页
     */
    @GetMapping("/bm/page")
    public ResultInfo getBmByPage(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "12") Integer size,
            String searchKey
    ) {
        JSONObject param = new JSONObject();
        param.put("current", current);
        param.put("size", size);
        param.put("kcmc", searchKey);
        param.put("jlmc", searchKey);
        param.put("khnc", searchKey);
        param = xyService.getBmByPage(param);
        return ResultInfo.success(param.get("aclientbms"));
    }

    /**
     * shihuijun 报名详细
     */
    @GetMapping("/bm/info")
    public ResultInfo getBmByInfo(@RequestParam String bmid) {

        JSONObject param = new JSONObject();
        param.put("bmid", bmid);
        param = xyService.getBm(param);
        return ResultInfo.success(param);
    }


}

